import { http } from '@/utils/http'
import { Department } from '@/service/menu/menu'

export interface StagePlan {
  planId: number
  planName: string
  planCode: string | null
  planType: number
  trainStage: number
  createTime: string
  createUser: number
  status: number
  lastUpdateTime: string
  approveStatu: number
  approveTime: string | null
  frontImage: string
  outLine: string
  phoneBigImg: string
  phoneSmallImg: string
  padBigImg: string
  padSmallImg: string
  openCrowd: string | null
  sortId: number
  indexStatus: number
  roleTags: string | null
  isComplete: boolean
}

export interface StageCourse {
  resId: number
  resName: string
  resType: number
  cateId: number
  cateName: string
  tags: string
  resImg: string
  resTime: string
  likeNum: number
  lookNum: number
  commentNum: number
  overTime: string
  openCrowd: string
  openCrowdOption: string
  cateImg: string
  isLike: number
  isCollect: number
  content: string
  cateContent: string
  webUrl: string
  isLook: number
  isCompele: number
  cpbProductIntroduction: string
  allowTimes: number
  testTimes: number
  timeLength: number
  optionKey: number
  products: string | null
  resCover: string
  cateCover: string
  startTime: string | null
  endTime: string | null
  cateNameEn: string
}

/* 获取阶段计划 */
export const getStagePlan = (): Promise<IResData<StagePlan[]>> => {
  return http.get<StagePlan[]>('/api/MP/GetBasicPlans')
}

/* 获取阶段课程 */
export const getStageCourses = (stage: number): Promise<IResData<StageCourse[]>> => {
  return http.get<StageCourse[]>('/api/MP/GetBasicTrainingList', { stage })
}

export interface CoursePlan {
  planId: number
  planName: string
  planCode: string | null
  trainStage: number
  frontImage: string
  courseCount: number
  examCount: number
  compCourseCount: number
  compExamCount: number
}

/* 我的任务-课程列表 */
export const getCoursePlanList = (): Promise<IResData<CoursePlan[]>> => {
  return http.get<CoursePlan[]>('/api/MP/GetCoursePlanList')
}

export interface CoursePlanListByIdResponse {
  plan: StagePlan
  courseList: StageCourse[]
  completedCourCount: number
  examList: any[]
  completedExamCount: number
  process: string
}

/* 课程计划列表 */
export const getCoursePlanListById = (
  planId: number,
): Promise<IResData<CoursePlanListByIdResponse>> => {
  return http.get<CoursePlanListByIdResponse>('/api/MP/GetCoursePlanListById', {
    planId,
  })
}
